/**
 * 
 */
package recognition.preprocessor;

import recognition.preprocessor.Preprocessor;
import utility.math.Homotecia;
import utility.math.Vector2D;
import handwritten.gesture.Gesture;
import handwritten.gesture.MultiGesture;

/**
 * @author tioz
 *
 */
public class LengthSetter extends Preprocessor {

	
	double target;
	
	
	/**
	 * 
	 */
	public LengthSetter(MultiGesture target) {
		this.target = target.pathLength();
	}
	public LengthSetter(double newSize) {
		this.target = newSize;
	}

	/* (non-Javadoc)
	 * @see recognition.preprocessor.Preprocessor#preprocess(handwritten.gesture.MultiGesture)
	 */
	@Override
	protected boolean preprocess(MultiGesture gest) {
		
		//System.out.println("setting length");
		
		double rapport = target/gest.pathLength();
		Homotecia homo = new Homotecia(gest.centerOfMass(),rapport);
		
		for(Gesture g : gest.getCollection())
		{
			for(Vector2D v : g.getPath())
			{
				homo.transform(v);
			}
		}
		
		return true;
	}
	
}
